#include <vector>
#include <map>
#include <string>

using namespace std;

void errprintline (const char *msg, int line);

class IPE
{
	private:
		vector<string> *instrs;
		// Unknown label's list
		multimap<string,int> LabelList;
		// Label index mapper
		map<string, int> LabelMap;
	public:
		IPE (vector<string> *instrs);
		~IPE ();
		
		// Parses an assembly file and returns the num of lines
		int ParseAssembly (char* fileName, int& mainIndex);
		// Parses and validates an instruction
		string ParseString (string instr);
		// Checks a string for valid instruction
		string ValidateString (string str, int lineCount);
		// Checks for labels, and replaces their names with instr nums
		void RecheckLabels ();
		// Parses and returns what must be done to CPU
		void ParseInstruction (string str, string& inst, string& param);
		void errprintline (char *msg, int line);
};
